﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class D09_LoadScene : MonoBehaviour
{
    private AsyncOperation async;
    public UnityEngine.UI.Slider slider;
    private void OnGUI()
    {
        if (GUILayout.Button("进入游戏-直接加载"))
        {
            SceneManager.LoadScene("Demo");
        }

        if (GUILayout.Button("进入游戏-异步加载"))
        {
            async = SceneManager.LoadSceneAsync("Demo");
        }

        //同步和异步都可以以附加场景的形式加载
        if (GUILayout.Button("进入游戏-异步加载"))
        {
            async = SceneManager.LoadSceneAsync("Demo", LoadSceneMode.Additive);
        }
    }

    private void Update()
    {
        if (async != null)
        {
            print(async.progress);//进度  取值范围  0-1   老版本  0-0.9
            slider.value = async.progress / 0.9f;
        }
    }
}